/**
 * 弹出窗口
 * 日期：2015-12-26
 * 可配参数:
 *title:标题
 * html:内容
 * callback:回调
 *
 **/
;(function ($) {
    'use strict';
    var Dialog = function (option) {
        var option = option || {},
            title = option.title || '',
            html = option.html || '',
            callback = option.callback || null,
            self = this;


        title = !title ? '': '<div class="dialog-title">' + title + '</div>';
        this.$boxHtml =$( ' <div class="d-mask"></div>\
                        <div class="dialog-box">\
                         '+title+'\
                        <div class="dialog-close"><i class="icon-l icon-close"></i></div>\
                            <div class="dialog-body">\
                            </div>\
                      </div>');

        self. $boxHtml.find('.dialog-body').html(html);
        $('body').append(self.$boxHtml);
        self.$boxHtml.find('.dialog-close').on('click', function () {
            self.$boxHtml.hide();
        });
        if(callback){
            callback();
        }
        
        
    };
     
    Dialog.prototype.open = function () {
    	this.$boxHtml.show();
    }
    
    Dialog.prototype.close = function () {
        this.$boxHtml.hide();
    }

    $.dialog = function (option) {
       var that = new Dialog(option);
       that.close();
       return  that;
    }
})(jQuery);